﻿<%@ Page Language="C#" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace=" System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="TarreOA.TarreOAModels" %>
<%@ Import Namespace="TarreOA.TarreOABLL" %>
<script runat="server">
    
    protected void Timer1_Tick(object sender, EventArgs e)
    {
        List<User> list = null;
        if (ViewState["thl_Id"] != null)
        {
            thl_Id = (int)ViewState["thl_Id"];
        }
        UserTalkContent utc = UserTalkContent.instance();
        if (utc.TalkUsers["Talk" + thl_Id.ToString()] != null)
        {
            list = ((List<User>)utc.TalkUsers["Talk" + thl_Id.ToString()]);
            
            if (list != null && list.Count > 0)
            {
                DataSet ds = new DataSet();
                DataTable dt = new DataTable();
                dt.Columns.Add("Username", typeof(string));
                dt.Columns.Add("UserLoginName", typeof(string));
                foreach (User user in list)
                {
                    DataRow dr = dt.NewRow();
                    dr["Username"] = "[" + user.UserName + "]";
                    dr["UserLoginName"] = user.LoginName;
                    dt.Rows.Add(dr);
                }
                ds.Tables.Add(dt);
                this.DataList1.DataSource = ds.Tables[0].DefaultView;
                this.DataList1.DataBind();
            }
            else
            {
                this.DataList1.DataSource = null;
                this.DataList1.DataBind();
            }
        }
        ViewState["thl_Id"] = thl_Id;
    }

    protected void DataList1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            string username = ((HyperLink)e.Item.FindControl("HylLoginUser")).Text;
            string loginName = ((HtmlInputHidden)e.Item.FindControl("HidUserLoginName")).Value;
            ((HyperLink)e.Item.FindControl("HylLoginUser")).Attributes.Add("onclick", "addTalkTarget('" + username + "','" + loginName + "')");
        }
    }

    private int thl_Id;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString.Get("thl_id") != null)
            {
                thl_Id = int.Parse(Request.QueryString.Get("thl_id"));
                ViewState["thl_Id"] = thl_Id;
            }
        }
    }
    
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript" src="../js/UserTalkHouse.js"></script>
    <link rel="Stylesheet" type="text/css" href="../Styles/right_style.css" />
    <script type="text/javascript" src="../Scripts/jquery.ui/js/jquery.js"></script>
    <style type="text/css"> 
        <!--
        html{ scrollbar-base-color: #dbecf8; scrollbar-arrow-color: #2a8ed1; scrollbar-track-color: #bdddf2; scrollbar-3dlight-color: #2886c5; scrollbar-darkshadow-color: #2886c5;
        scrollbar-face-color: #dbecf8; scrollbar-shadow-color: #dbecf8;  }
        -->
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline">
        <ContentTemplate>
            <asp:Repeater ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound">
            <HeaderTemplate>
                    <table width="99%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#77acd0"
            style="border-collapse: collapse;">
            <tr bgcolor="#b1d5ef">
                <td align="center" height="30px">
                    <b>在线人员</b>
                </td>
            </tr>
            </HeaderTemplate>
                <ItemTemplate>
                    <tr><td>
                        <asp:HyperLink ID="HylLoginUser" runat="server" NavigateUrl="#" Font-Underline="false"
                            Text='<%# Eval("Username") %>'></asp:HyperLink>
                        <input id="HidUserLoginName" runat="server" style="width: 62px" type="hidden" value='<%# Eval("UserLoginName") %>' />
                    </td></tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
            <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
            </asp:Timer>
        </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>
